<template>
  <a-modal
    :title="title"
    :width="1200"
    :visible="visible"
    :maskClosable="false"
    :confirmLoading="confirmLoading"
    :okButtonProps="{ props: {disabled: disableSubmit} }"
    @ok="handleOk"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <!-- 主表单区域 -->
      <a-form :form="form">
        <a-card type="inner" title="项目信息">
<!--        <a-divider orientation="left" style="color: #00A0E9;margin-left:-11px ">项目信息</a-divider>-->
          <a-row :gutter="24">
            <a-col :span="8">
              <a-form-item label="单位名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-input v-decorator="['office']" :trigger-change="true" :disabled='disBool'/>
              </a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="系统名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-input v-decorator="[ 'systemName', validatorRules.systemName]" placeholder="请输入系统名称" readonly="readonly"></a-input>
              </a-form-item>
            </a-col>
          </a-row>
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-item label="信息化负责人" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="[ 'principal', validatorRules.principal]" placeholder="请输入信息化负责人" readonly="readonly"></a-input>
            </a-form-item>
          </a-col>
        <!--负责人联系电话-->
          <a-col :span="8">
            <a-form-item label="联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="[ 'principalPhone', validatorRules.principalPhone]" placeholder="请输入负责人联系电话" readonly="readonly"></a-input>
            </a-form-item>
          </a-col>
        <!--负责人邮箱-->
          <a-col :span="8">
            <a-form-item label="邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="[ 'principalMail', validatorRules.principalMail]" placeholder="请输入负责人邮箱" readonly="readonly"></a-input>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-item label="联系人" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="[ 'linkman', validatorRules.linkman]" placeholder="请输入联系人" readonly="readonly"></a-input>
            </a-form-item>
          </a-col>
          <!--联系人联系电话-->
          <a-col :span="8">
            <a-form-item label="联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="[ 'linkmanPhone', validatorRules.linkmanPhone]" placeholder="请输入联系人联系电话" readonly="readonly"></a-input>
            </a-form-item>
          </a-col>
        <!--联系人邮箱-->
          <a-col :span="8">
            <a-form-item label="邮箱" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="[ 'linkmanMail', validatorRules.linkmanMail]" placeholder="请输入联系人邮箱" readonly="readonly"></a-input>
            </a-form-item>
          </a-col>
        </a-row>
        </a-card>
      </a-form>
      <!-- 子表单区域 -->
      <a-tabs v-model="activeKey" @change="handleChangeTabs">
        <a-tab-pane tab="云服务器信息" :key="refKeys[0]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[0]"
            :loading="jinanGovernmentLedgerAttachedTable.loading"
            :columns="jinanGovernmentLedgerAttachedTable.columns"
            :dataSource="jinanGovernmentLedgerAttachedTable.dataSource"
            :maxHeight="300"
            :rowNumber="true"
            :rowSelection="true"
            :actionButton="false"/>
        </a-tab-pane>
      </a-tabs>
    </a-spin>
    <template slot="footer">
      <a-button key="back" @click="handleCancel">关闭</a-button>
    </template>
  </a-modal>
</template>

<script>

  import pick from 'lodash.pick'
  import { VALIDATE_NO_PASSED,FormTypes,getRefPromise,validateFormAndTables } from '@/utils/JEditableTableUtil'
  import { JEditableTableMixin,getAllTable,request } from '@/mixins/JEditableTableMixin'
  import JDate from '@/components/jeecg/JDate'  
  import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
  import JMultiSelectTag from "@/components/dict/JMultiSelectTag"
  import JUpload from '@/components/jeecg/JUpload'
  import ACol from "ant-design-vue/es/grid/Col";

  export default {
    name: 'cloudServerManagementModel',
    mixins: [JEditableTableMixin],
    components: {
      ACol,
      JDate,
      JSelectDepart,
      JMultiSelectTag,
      JUpload
    },
    data() {
      return {
        // orderMainModel: {jeecgOrderCustomerList: [{}],
        //   },
        labelCol: {
          span: 6
        },
        wrapperCol: {
          span: 16
        },
        labelCol2: {
          span: 3
        },
        wrapperCol2: {
          span: 20
        },
        visible: false,
        disBool:true,
        disableSubmit:false,
        // 新增时子表默认添加几行空数据
        // addDefaultRowNum: 1,
        validatorRules: {
          updateTime:{},
          office:{},
          principal:{},
          principalPhone:{rules: [{validator: this.validatePhone}]},
          principalMail:{rules: [{validator: this.validateEmail}]},
          linkman:{},
          linkmanPhone:{rules: [{validator: this.validatePhone}]},
          linkmanMail:{rules: [{validator: this.validateEmail}]},
          systemName:{},
          mainUses:{},
          tos:{},
        },
        refKeys: ['JinanGovernmentledgerAttached',],
        tableKeys:['JinanGovernmentledgerAttached',],
        activeKey: 'JinanGovernmentledgerAttached',
        // 服务器申请附表
        jinanGovernmentLedgerAttachedTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '云服务器名称',
              key: 'serverName',
              type: FormTypes.input,
              defaultValue: '',
              align:"center",
              disabled:"true",
            },
            {
              title: '数量',
              key: 'num',
              type: FormTypes.input,
              defaultValue: '',
              align:"center",
              disabled:"true",
            },
            {
              title: 'CPU',
              key: 'cpu',
              type: FormTypes.input,
              defaultValue: '',
              align:"center",
              disabled:"true",
            },
            {
              title: '内存',
              key: 'memory',
              type: FormTypes.input,
              defaultValue: '',
              align:"center",
              disabled:"true",
            },
            {
              title: '云硬盘',
              key: 'disk',
              type: FormTypes.input,
              defaultValue: '',
              align:"center",
              disabled:"true",
            },
            {
              title: '审核CPU(核)',
              key: 'auditCpu',
              type: FormTypes.inputNumber,
              defaultValue: '',
              align:"center",
              disabled:"true",
            },
            {
              title: '审核内存(G)',
              key: 'auditMemory',
              type: FormTypes.inputNumber,
              defaultValue: '',
              align:"center",
              disabled:"true",
            },
            {
              title: '审核云硬盘(G)',
              key: 'auditDisk',
              type: FormTypes.inputNumber,
              defaultValue: '',
              align:"center",
              disabled:"true",
            },
            {
              title: '数据库类类型',
              key: 'dataBase',
              type: FormTypes.select,
              defaultValue: '',
              width: '8%',
              align:"center",
              dictCode:"jinan_data_base,dataBase_name,id",
              // dictCode:"dataBase_dictText",
              disabled:"true",
            },
            {
              title: '内部地址',
              key: 'intranetIp',
              type: FormTypes.select,
              defaultValue: '',
              align:"center",
              disabled:"true",
            },
            {
              title: '互联网IP地址',
              type: FormTypes.select,
              defaultValue: '',
              key: 'ipSite',
              options: [],
              align:"center",
              disabled:"true",
              validateRules:[]
            },
            {
              title: '开通时间',
              key: 'openTime',
              type: FormTypes.date,
              defaultValue: '',
              width: '8%',
              align:"center",
              disabled:"true",
            },
            {
              title: '运行状态',
              key: 'status',
              type: FormTypes.select,
              defaultValue: '',
              align:"center",
              disabled:"true",
              options: [ // 下拉选项
                { title: '在用', value: '0' },
                { title: '在用', value: '1' },
                { title: '注销', value: '2' },
                { title: '停用', value: '3' }
              ],
            },
            {
              title: '上次结算时间',
              key: 'lastPayTime',
              type: FormTypes.input,
              defaultValue: '',
              width: '8%',
              align:"center",
              disabled:"true",
            },
            {
              title: '累计运行时间(天)',
              key: 'runningTime',
              type: FormTypes.input,
              defaultValue: '',
              align:"center",
              disabled:"true",
            }
          ]
        },
        url: {
          // edit: "/jinanAudit/auditMain/edit",
          cloudServiceProject: {
            list: '/jinanCloud/cloudServiceProject/findByMainId'
          },
        }
      }
    },
    methods: {
      // edit(record){
        /** 调用完edit()方法之后会自动调用此方法 */
        editAfter() {
        debugger
        // this.form.resetFields();
        // this.model = Object.assign({}, record);
        // this.visible = true;
        // this.$nextTick(() => {
        //   this.form.setFieldsValue(pick(this.model,'office','principal','principalPhone','principalMail','linkman','linkmanPhone','linkmanMail','systemName','mainUses','tos','filePath'))
        // });
        //
          let fieldval = pick(this.model,'updateTime','office','principal','principalPhone','principalMail','linkman','linkmanPhone','linkmanMail','systemName','mainUses','tos','type','remarks'
            ,'openTime','ipSite','vpn','auditMoney','applyMoney','saveMoney','auditFilePath')
          this.$nextTick(() => {
            this.form.setFieldsValue(fieldval)
          })
        // 加载子表数据
        if (this.model.id) {
          let params = { id: this.model.id }
          this.requestSubTableData(this.url.cloudServiceProject.list, params, this.jinanGovernmentLedgerAttachedTable)
        }
      },
      // /** 整理成formData */
      // classifyIntoFormData(allValues) {
      //   debugger
      //   let main = Object.assign(this.model, allValues.formValue)
      //
      //   return {
      //     ...main, // 展开
      //     cloudServiceProjectdList: allValues.tablesValue[0].values,
      //   }
      // },
      handleCancel () {
        this.close()
      },

    }
  }
</script>

<style scoped>
</style>